﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;
using BrokerBase.Lib.Product;

namespace broker.duty.YG
{
    class ProudctExander : AbstractProductExpander
    {
        private PolicyTarget pt;
        /// <summary>
        /// 保单加载完成
        /// </summary>
        /// <param name="policy"></param>
        public override void Loaded(IPolicy policy)
        {

            policy.Amount = policy.Owner.BasicPolicy.Amount;

            IPaymentPeriod bpp=policy.Owner.BasicPolicy.SelectedPaymentPeriod;

            policy.SelectedPaymentPeriod = policy.Product.PaymentPeriods.First(p => p.Style == bpp.Style && p.Value == bpp.Value);

            IInsurancePeriod ipp = policy.Owner.BasicPolicy.SelectedInsurancePeriod;

            policy.SelectedInsurancePeriod = policy.Product.InsurancePeriods.First(p => p.Style == ipp.Style && p.Value == ipp.Value);

            policy.SelectedRowRateFactors["给付比例"] = policy.Owner.BasicPolicy.SelectedRowRateFactors["给付比例"];

            policy.SelectedRowRateFactors["领取年龄"] = policy.Owner.BasicPolicy.SelectedRowRateFactors["领取年龄"];

            policy.SetSettingLock("Amount", true);
            policy.SetSettingLock("给付比例", true);
            policy.SetSettingLock("领取年龄", true);
            policy.SetSettingLock("缴费期限", true);

            policy.Amount = policy.Owner.Policies.Sum(p => p.TotalFee);


            policy.Amount = policy.Owner.BasicPolicy.Fee;
        }

        public override bool IsDecimal
        {
            get
            {
                return true;
            }
        }
    }

    
}
